package com.atguigu.tingshu;

import com.atguigu.tingshu.common.constant.RedisConstant;
import com.xpand.starter.canal.annotation.EnableCanalClient;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@Slf4j
@EnableCanalClient          // 声明当前这个微服务是canal的客户端
public class ServiceAlbumApplication implements CommandLineRunner {

    @Autowired
    private RedissonClient redissonClient ;

    public static void main(String[] args) {
        SpringApplication.run(ServiceAlbumApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        RBloomFilter<Long> rBloomFilter = redissonClient.getBloomFilter(RedisConstant.ALBUM_BLOOM_FILTER);
        rBloomFilter.tryInit(10000000 , 0.0001) ;
        log.info("布隆过滤器初始化成功了....");
    }
}
